package com.venutech.gongan.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.utils.PageUtils;
import com.venutech.gongan.dao.JkxtMapper;
import com.venutech.gongan.entity.Jkxt;
import com.venutech.gongan.model.ResultFormat;
import com.venutech.gongan.service.JkxtService;
import com.venutech.gongan.util.ResultUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class JkxtServiceImpl implements JkxtService {
    @Resource
    private JkxtMapper jkxtMapper;


    @Override
    public ResultFormat insert(Jkxt jkxt) {
        Integer insert = jkxtMapper.insert(jkxt);
        if (insert > 0) {
            return ResultUtil.success();
        }else {
            return ResultUtil.error(100,"添加失败");
        }
    }

    @Override
    public int deleteById(Integer jk_id) {
        return jkxtMapper.deleteById(jk_id);
    }

    @Override
    public Jkxt getById(Integer jk_id) {
        return jkxtMapper.getById(jk_id);
    }

    @Override
    public int updateJkxt(Jkxt jkxt) {
        return jkxtMapper.updateJkxt(jkxt);
    }

    @Override
    public List<Jkxt> getSelectAll() {
        return jkxtMapper.getSelectAll();
    }

    @Override
    public Page<Jkxt> getInfo(Integer pageNo, Integer pageSize, String begintime, String endtime, String badw, String jk_name) {
        Page<Jkxt> page = new Page<>(pageNo,pageSize);
        PageUtils.startPage();
        List<Jkxt> list = jkxtMapper.getInfo(begintime,endtime,badw,page,jk_name);
        page.setTotal(new PageInfo<>(list).getTotal());
        return page.setRecords(list);
    }
}
